<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="com.ai.core.util.Configure"%>
<%@ page import="com.ai.wx.util.WeixinUtil"%>
<%@ page import="com.ai.wx.entity.AgentUser"%>
<%@ page import="com.ai.core.constant.GlobalConstant"%>

 
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-control" content="max-age=1700" />
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
<meta name="MobileOptimized" content="320" />
<meta name="format-detection" content="telephone=no" />


<script type="text/javascript" src="${ctx}/js/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/js/common.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<link href="${ctx}/css/box.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/css/agentUser.css" rel="stylesheet" type="text/css" />

<title>推广金提取</title>
<script>
    var maxMoney = ${agentBrokerage.DCharge};
    wx.config({
        debug: true,
        appId: '<%=Configure.getAppId()%>',
        timestamp: ${JsSign.timestamp},
        nonceStr: '${JsSign.nonce}',
        signature: '${JsSign.signature}',
        jsApiList: [
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'hideMenuItems',
            'showMenuItems',
            'hideAllNonBaseMenuItem',
            'showAllNonBaseMenuItem',  
            'chooseImage',
            'previewImage',
            'uploadImage',
            'downloadImage',
            'getNetworkType', 
            'hideOptionMenu',
            'showOptionMenu',
            'closeWindow',   
          ]
    });

    wx.ready(function () { 
         
         $('#brokerageDrawBtn').click(function(){
             var value = $('#drawCharge').val(); 
             if(value==''){
                 alert('请填写提取金额');
                 return;
             }
             if (isNaN(value)) {
                 alert('金额请填写数字');
                 return;
             }
             if(value > maxMoney ){
                 alert('超过提取最大限额');
                 return;
             } 
             $.ajax({ 
                 url: '${ctx}/agent/applyDrawBrokerage',
                 type: 'POST',
                 data: $('#brokerageDrawForm').serializeObject(),
                 cache:false,
                 dataType:'json',  
                 success: function(data){  
                     if(data.success){
                         alert('申请提交成功，请等待审核');
                         window.location.href='${ctx}/agent/brokerageDrawLock'; 
                     }/* else{
                         alert('申请提交失败，错误原因：'+data.msg);
                     } */
                 },
                 error : function(data) {    
                     console.info(data);
                 }    
             });
         });
    });
    
    /* wx.error(function (res) {
      alert(res.errMsg);
    });  */
</script>
</head>
<body>
    <form id="brokerageDrawForm" class="ui-form" name="" method="post"  action="#" id="">
        <fieldset>
            <div id="main"> 
                
                <div class="ui-form-item">
                    <label for="" class="ui-label">金额 </label> <input class="ui-input"
                        type="tel" id="drawCharge" name="drawCharge" maxlength="20" placeholder="当前推广金余额${agentBrokerage.DCharge}元"  style="ime-mode:Disabled"> 
                        <span class="ui-form-other"></span> 
                </div>
                
                 
                <div class="ui-form-item">
                    <div class="button">
                        <input id="brokerageDrawBtn" type="button" class="ui-button ui-button-morange" value="申请提取">
              
                    </div>
                </div>

            </div>
        </fieldset>
    </form>
</body>
</html>




